﻿
using UnityEngine;

public class PlayerClimb : PlayerBaseState {
	//Vector2 _climbSpeed;
	//bool _animStart;
	//bool _canExit;
	public PlayerClimb(PlayerController controller, PlayerStateEnum stateName, State<PlayerStateEnum> superFSM, StateFactory<PlayerStateEnum> factory) : base(controller, stateName, superFSM, factory) {
		AddConditionToSelf(() => _controller.IsTouchingEdge);

		//AddNewTransition(PlayerStateEnum.WallIdle, () => !(controller.Up || controller.DownInput) && _canExit);
		//_climbSpeed = new Vector2(0, controller.ConfigData.WallClimbSpeed);
	}

	public override void Enter() {
		_controller.PlayAnim(PlayerStateEnum.Climb);
		_controller.Velocity = Vector2.zero;
		//_animStart = false;
	}
	public override void Update() {
		base.Update();
		if (_controller.IsAnimPlayOver()) {
			//_canExit = true;
			//MovePosition(_controller.transform);
		}
	}
	public override void Exit() {
	}
	void MovePosition(Transform transform) {
		var dir = _controller.StateData.FaceDir;
		var off = _controller.ConfigData.ClimbEdgeOffset;
		float newX = transform.position.x + dir * off.x;
		float newY = transform.position.y + off.y;
		transform.position = new Vector3(newX, newY, transform.position.y);
		//Debug.Log("MovePosition");
	}
}